export const rmEptAttr = obj => {
  Object.keys(obj).forEach(key => {
    if ([undefined, null].includes(obj[key])) {
      delete obj[key];
    }
  });
  return obj;
};

export const create = (obj = {}, keys = []) => {
  let key = "";
  let current = obj;
  while ((key = keys.shift())) {
    if (!current[key]) current[key] = {};
    current = current[key];
  }
  return obj;
};

/**
 * @name 序列化对象
 */
export const objSerialize = (obj = {}) => {
  let data = "";
  Object.keys(obj).forEach((key, index) => {
    if (index == 0) {
      data += "?" + key + "=" + obj[key];
    } else {
      data += "&" + key + "=" + obj[key];
    }
  });
  return data;
};
